vendredi 5 septembre 2008
Convertir BitArray en Int
Par Promesses, vendredi 5 septembre 2008 à 10:01 :: ASP.Net
J'ai eu besoin de convertir un BitArray en Int et voici ce que j'ai trouvé sur le net.
BitArray mask = New BitArray int[] array = new int[1]; mask.CopyTo(array, 0); return array[0];
{{The following property exposes a 32-bit System.Collections.BitArray as a System.Int32. To convert the BitArray to an integer, the get accessor method (1) creates a 1-element array of integers, (2) copies the BitArray to the array using the CopyTo method, and (3) returns the one and only element of the array. To convert the integer value back to a BitArray, the set accessor method constructs a new BitArray object from an array of integers whose only element is the integer value.
using System.Collections;}}